<?php
/**
 * Created by PhpStorm.
 * User: xi
 * Date: 2020-05-02
 * Time: 16:54
 */

namespace app\api\service;


use app\admin\model\Cmdlog;
use app\admin\model\Devicecmd;
use app\admin\model\Roomclean;
use app\admin\model\Shopdevice;
use app\admin\model\Shoporder;
use app\admin\model\Shoporderprofit;
use app\admin\model\Shoproom;
use app\admin\model\Shoproombook;
use app\admin\model\Shopstaff;
use app\admin\model\Userorderprofit;
use app\admin\model\Usertuan;
use app\admin\model\Userwithdraw;

class DeviceService
{

    public function ship($req = array())
    {

        $openCmdUrl = "http://47.97.67.38:8181/cc/ship";
        $param = array();
        $param['orderNo'] = $req['order_no'];
        $param['slot'] = $req['slot'];
        $param['deviceId'] = $req['device_id'];

        $ret = http_post_json($openCmdUrl, json_encode($param));
        $ret = json_decode($ret, true);
        if ($ret['code'] == 0) {
            $msg = "正在打开中";
        }

        $deviceCmdModel = new Devicecmd();
        $db['device_id'] = $req['device_id'];
        $db['order_no'] = $req['order_no'];
        $db['slot'] = $req['slot'];
        $db['create_time'] = time();
        $db['user_id'] = $req['user_id'];
        $db['type'] = "order";
        $db['is_test'] = -1;
        $deviceCmdModel->insert($db);
    }

    public function test($req = array())
    {
        $openCmdUrl = "http://47.97.67.38:8181/cc/test";
        $param = array();
        $param['orderNo'] = $req['order_no'];
        $param['slot'] = $req['slot'];
        $param['deviceId'] = $req['device_id'];

        $ret = http_post_json($openCmdUrl, json_encode($param));
        $ret = json_decode($ret, true);
        if ($ret['code'] == 0) {
            $msg = "正在打开中";
        }
        $deviceCmdModel = new Devicecmd();
        $db['device_id'] = $req['device_id'];
        $db['order_no'] = $req['order_no'];
        $db['slot'] = $req['slot'];
        $db['create_time'] = time();
        $db['user_id'] = $req['user_id'];
        $db['type'] = "order";
        $db['is_test'] = 1;
        $deviceCmdModel->insert($db);
    }

}